import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute, ParamMap } from '@angular/router';

import { PhotoService } from '../../service/photo.service';

import { Photo } from '../../domain/photo';

@Component({
  selector: 'photo-list',
  templateUrl: './photo-list.component.html',
  styleUrls: ['./photo-list.component.css'],
  providers: [PhotoService]
})
export class PhotoListComponent implements OnInit {

  photos: Photo[];

  constructor(
    private photoService: PhotoService,
    private router: Router
  ) { }

  ngOnInit() {
    this.photoService.getPhotos()
    .then(photos => {this.photos = photos;
    });
  }

  onSelect(photo: Photo){
    this.router.navigate(['/photo-detail',photo.id]);
  }

}
